<!DOCTYPE html>
<html>

<head>
    <title>充值</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1,user-scalable=no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/reset.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/flex.css">
    <link rel="stylesheet" type="text/css" href="/resource/web/css/accounts-child.css">
    <script type="text/javascript" src="/resource/web/js/flexible.js"></script>
    <script type="text/javascript" src="/resource/web/js/jquery-1.11.1.min.js"></script>
</head>

<body>
<form id="submit_deposit_form" action="/Web/web_user_deposit_recharge" method="post" target="_blank">
    <div class="title">
        <p>充值</p>
        <a href="/Web/user_accounts"><img class="back" src="/resource/web/img/newhead/path_7_copy.png"></a>
    </div>
    <div class="withdraw">
        @if(empty($bankcard))
        <script> alert("您还未实名认证");location='/Web/webauth_name.html';</script>
        @else
            <div class="wd-back">
                <p class="back-ico"><img src="{{$bankcard->bank_logo}}"></p>
                <p class="bk-name">{{$bankcard->bank_name}}</p>
                <p class="bk-num">尾号{{substr($bankcard->bank_num,-4)}}</p>
                <img class="dw-r" src="/resource/web/img/finacing/go_r3.png">
            </div>
        @endif
        <div class="wd-mon">
            <p>
                充值金额<input type="number" name="amount" id="input_amount" placeholder="请输入充值金额">
            </p>
        </div>
        <span id="error" class="errs"></span>
        <div class="wd-mon">
            <p class="sxf">账户余额<span>{{$recharge['fund']->money_format}}元</span></p>
        </div>
        <a href="#0" id="submit_deposit"><div class="wd-btn">确定</div></a>
        <p class="wdtishi">客服电话：&nbsp400-900-9017</p>
    </div>
</form>

    <script type="text/javascript" src="/resource/js/gpw/main.js"></script>
    <script>
        $(".cd-popup .cd-popup-container").css({"height":"280px","margin-top":"10%"});
        // 提交充值
        $('#input_amount').focus(function(){
            $("#error").html('');
        })
        $('#submit_deposit').click(function(){
            var amount = $.trim($('#input_amount').val());
            if (amount == '' || amount == null)
            {
                alert("请输入充值金额, 至少2元");
                //var index = $("#error").html('请输入充值金额, 至少2元');
                return ;
            }else{
                $("#error").html('');
            }

            if (isNaN(amount))
            {
                alert("'请输入充值金额, 充值金额只能是纯数字'");
               // var index = $("#error").html('请输入充值金额, 充值金额只能是纯数字');
                return ;
            }else{
                $("#error").html('');
            }

            if (amount < 2)
            {
                alert('请输入充值金额, 至少2元');
                //var index = $("#error").html('请输入充值金额, 至少2元');
                return ;
            }else{
                $("#error").html('');
            }
            if (amount >= 10000000)
            {
                alert('每笔充值金额不能超过 10,000,000 元');
                //var index = $("#error").html('每笔充值金额不能超过 10,000,000 元');
                return ;
            }else{
                $("#error").html('');
            }
            $.ajax({
                url      : '/Web/web_user_deposit_recharge',
                type     : 'post',
                data     : 'amount='+amount,
                async    : false,
                timeout  : 25,
                error : function (xmlHttpRequest, error) {
                    var errorMsg = (error == 'timeout') ? '网络可能不给力哦，请重试...' : '服务器繁忙，请稍候再试';
                    alert(errorMsg);
                },
                success : function (redata)
                {
                    if (redata == 200)
                    {
                        $("#error").html('');
                        $('#submit_deposit_form').submit();
                    }
                    else
                    {
                        alert(redata);
                        return;
                        //$("#error").html(redata);
                    }
                }
            });
        });
    </script>

</body>

</html>
